<!-- 引用编辑器 -->
<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script src="/static/kindeditor/kindeditor-all.js"></script>
<script src="/static/kindeditor/lang/zh-CN.js"></script>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md8 content detail">
        <div class="fly-panel detail-box">
          <h1>{$post.title}</h1>
          <div class="fly-detail-info">
            <!-- <span class="layui-badge">审核中</span> -->
            <span class="layui-badge layui-bg-green fly-detail-column">{$post.cate.name}</span>
            
            
            {if condition="$post.accept > 0"}
                <span class="layui-badge" style="background-color: #5FB878;">已结</span>
            {else /}
                <span class="layui-badge" style="background-color: #999;">未结</span>
            {/if}
            {if condition="$post.state == 1"}
            <span class="layui-badge layui-bg-black">置顶</span>
            {elseif condition="$post.state == 2"}
            <span class="layui-badge layui-bg-red">热门</span>
            {elseif condition="$post.state == 3"}
            <span class="layui-badge layui-bg-orange">精华</span>
            {/if}
            <div class="fly-admin-box" data-id="123">
                {if condition="$post.userid == $userid"}
                    <span class="layui-btn layui-btn-xs jie-admin del" data-id="{$post.id}" type="del">删除</span>
                {/if}

                {if condition="$post.userid != $userid && $LoginUser"}
                  {if condition="$collect == $userid"}
                    <span class="layui-btn layui-btn-xs jie-admin layui-bg-red uncollect" data-id="{$post.id}" type="set" field="stick" rank="1">取消收藏</span> 
                  {else /}
                    <span class="layui-btn layui-btn-xs jie-admin collect" data-id="{$post.id}" type="set" field="stick" rank="0">收藏</span>
                  {/if}
                {/if}
              <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="1">加精</span>  -->
              <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="0" style="background-color:#ccc;">取消加精</span> -->
            </div>
            <span class="fly-list-nums"> 
              <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i> {$post.comment_count}</a>
              <i class="iconfont" title="人气">&#xe60b;</i> {$VisitCount}
            </span>
          </div>
          <div class="detail-about">
            <a class="fly-avatar" href="{:url('home/user/index',['userid' => $post.userid])}">
              <img src="{$post.user.avatar_cdn}" alt="贤心">
            </a>
            <div class="fly-detail-user">
              <a href="{:url('home/user/index',['userid' => $post.userid])}" class="fly-link">
                <cite>{$post.user.nickname}</cite>
                <i class="iconfont icon-renzheng" title="认证信息：{$post.user.nickname}"></i>
                <i class="layui-badge fly-badge-vip">VIP {$post.user.vip}</i>
              </a>
              <span>{$post.createtime}</span>
            </div>
            <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
              <span style="padding-right: 10px; color: #FF7200">悬赏：{$post.point}积分</span>
              {if condition="$post.userid == $userid"}
                <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="{:url('home/post/edit',['postid' => $post.id])}">编辑此贴</a></span>
              {/if}
            </div>
          </div>
          <div class="detail-body photos">
            {$post.content}
          </div>
        </div>
  
        <div class="fly-panel detail-box" id="flyReply">
          <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
            <legend>回帖</legend>
          </fieldset>
  
          <ul class="jieda" id="jieda">
            
            {if condition="$CommentList"}

              {:CommentHtml($CommentList,$post)}
            {else /}
              <!-- 无数据时 -->
              <li class="fly-none">消灭零回复</li>
            {/if}
          </ul>
          
          <div class="layui-form layui-form-pane">
            <form action="{:url('home/comment/add')}" method="post">
              <div class="layui-form-item layui-form-text">
                <a name="comment"></a>
                <div class="layui-input-block">
                  <textarea name="content" id="content" style="height: 300px;width:100%;"></textarea>
                  <!-- <textarea id="L_content" name="content" required lay-verify="required" placeholder="请输入内容"  class="layui-textarea fly-editor" style="height: 150px;"></textarea> -->
                </div>
              </div>
              <div class="layui-form-item">
                <input type="hidden" name="postid" value="{$post.id}">
                <input type="hidden" name="pid" value="">
                <button class="layui-btn" lay-filter="*" lay-submit>提交回复</button>
              </div>
            </form>
          </div>
        </div>
      </div>
      <div class="layui-col-md4">
        <dl class="fly-panel fly-list-one">
          <dt class="fly-panel-title">本周热议</dt>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
          <dd>
            <a href="">基于 layui 的极简社区页面模版</a>
            <span><i class="iconfont icon-pinglun1"></i> 16</span>
          </dd>
  
          <!-- 无数据时 -->
          <!--
          <div class="fly-none">没有相关数据</div>
          -->
        </dl>
  
        <div class="fly-panel" style="padding: 20px 0; text-align: center;">
          <img src="../../res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
          <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
        </div>
  
      </div>
    </div>
  </div>

<script>
  KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content"]');
  })
  layui.use(['layer'],function(){
    var $ = layui.jquery,
    layer = layui.layer

    $('.del').click(function(){

      var postid = $(this).data('id')

      layer.confirm('确认删除帖子？',{icon: 3, title:'提示'},function(index){
        
        // 发起请求
        $.ajax({
          type:'post',
          url:`{:url('home/post/del')}`,
          data:{
            postid
          },
          dataType:'json',
          success:function(res)
          {
            if(res.code === 1)
            {
              layer.msg('删除成功',{icon: 1},function(index){
                location.href = res.url
              })
            }else{
              layer.msg(res.msg,{icon: 5})
            }
          }
        })
        

        layer.close(index)
      })
    })


    $('.fly-admin-box').on('click','.collect',function(){

      var postid = $(this).data('id')

      layer.confirm('确认收藏帖子？',{icon: 3, title:'提示'},function(index){

        $.ajax({
          type:'post',
          url:`{:url('home/collect/collect')}`,
          data:{
            postid
          },
          dataType:'json',
          success:function(res)
          {
            if(res.code === 1)
            {
              layer.msg(res.msg,{icon: 1},function(){
                $('.collect').addClass('layui-bg-red').text('取消收藏').addClass('uncollect').removeClass('collect')
              })
            }
          }
        })
        layer.close(index)
      })
    })


    $('.fly-admin-box').on('click','.uncollect',function(){

      var postid = $(this).data('id')

      layer.confirm('确认取消收藏帖子？',{icon: 3, title:'提示'},function(index){

        $.ajax({
          type:'post',
          url:`{:url('home/collect/collect')}`,
          data:{
            postid
          },
          dataType:'json',
          success:function(res)
          {
            if(res.code === 1)
            {
              layer.msg(res.msg,{icon: 1},function(){
                $('.uncollect').removeClass('layui-bg-red').text('收藏').addClass('collect').removeClass('uncollect')
              })
            }
          }
        })
        layer.close(index)
      })
    })

  })
</script>